#!/user/bin/env python3
# -*- coding: utf-8 -*-
"""
--------------------------------------
    Author:     JiChao_Song
    Date  :     2020/11/13 12:16
    Desc  :
--------------------------------------
"""
import os
import time

from flask import Flask, request
from flask_cors import *
from flask_mongoengine import MongoEngine
from flask_sqlalchemy import SQLAlchemy
from flask_script import Manager
from flask_bootstrap import Bootstrap


class Application(Flask):

    def __init__(self, import_name, root_path=None):
        super(Application, self).__init__(import_name, root_path = root_path)

        # 加载配置文件
        self.config.from_pyfile("config/dev.py")

        # 加载SQLAlchemy
        db.init_app(self)

        mongo.init_app(self)

# sqldb
db = SQLAlchemy()

# mongodb
mongo = MongoEngine()

app = Application(__name__, root_path = os.getcwd())

# 跨域设置
CORS(app, supports_credentials=True)

manager = Manager(app)

bootstrap = Bootstrap(app)
